// SPDX-FileCopyrightText: 2023 CitruS Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

package com.fanwj.citrus.overlay.model

import kotlinx.parcelize.Parcelize
import com.fanwj.citrus.aidl.IBackend

typealias OverlayControlData = IBackend.OverlayControlData

fun OverlayControlData.positionFromLayout(layout: OverlayLayout): Pair<Double, Double> =
    when (layout) {
        OverlayLayout.Landscape -> Pair(landscape_position_x, landscape_position_y)
        OverlayLayout.Portrait -> Pair(portrait_position_x, portrait_position_y)
        OverlayLayout.Foldable -> Pair(foldable_position_x, foldable_position_y)
    }

fun OverlayControlData.initialize(id: String,
                         enabled: Boolean,
                         landscapePosition: Pair<Double, Double>,
                         portraitPosition: Pair<Double, Double>,
                         foldablePosition: Pair<Double, Double>): OverlayControlData
{
    this.id = id
    this.enabled = enabled
    this.landscape_position_x = landscapePosition.first
    this.landscape_position_y = landscapePosition.second
    this.portrait_position_x = portraitPosition.first
    this.portrait_position_y = portraitPosition.second
    this.foldable_position_x = foldablePosition.first
    this.foldable_position_y = foldablePosition.second
    return this
}